package kuang;

/**
 * @author cyt
 * @create 2020-03-07 14:49
 */
public class damon {
    public static void main(String[] args) {
        You you = new You();
        God god = new God();
        Thread y = new Thread(you);
        Thread g = new Thread(god);
        g.setDaemon(true);
        // 设置为守护进程，虚拟不会考虑守护进程是否开启
        // 用户进程一旦结束，虚拟机也会直接结束，而不考虑守护进程。
        y.start();
        g.start();
    }
}

class You implements Runnable {
    @Override
    public void run() {
        for (int i = 0; i < 365; i++) {
            System.out.println("我在活着");
        }
        System.out.println("我死了");
    }
}

class God implements Runnable {
    @Override
    public void run() {

        while (true) {
            System.out.println("上帝守护你");
        }
    }
}
